<!DOCTYPE html>
<html>

<head lang="en">
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<title>{{webtitle}}-爬虫数据监控系统</title>
	<link rel="stylesheet" href="static/css/bootstrap.min.css" />
	<link rel="stylesheet" href="static/css/bootstrap-theme.min.css" />
	<link rel="stylesheet" href="static/css/bootstrap-table.min.css" />
</head>

<body>
	<div class="container">
		<div id="toolbar" class="fixed-table-toolbar" style="white-space: nowrap;">
			<h2>{{webtitle}}-爬虫数据监控系统</h2>
			<form action="index" method="get">
				<input name="text" style="width: 45%;display: inline-block;" placeholder="请输入搜索内容" value="{{text}}" class="form-control"
				/> &nbsp;来源:
				<select name="source" id="source" onchange="onSelect(this)" style="display: inline-block;width: 25%;padding-left: 0px;" class="form-control">
					{% for item in sources %}
					{% if item == source %}
					<option selected="selected" value="{{item}}">{{item}}</option>
					{% else %}
					<option value="{{item}}">{{item}}</option>
					{% endif %}
					{% endfor %}
				</select> &nbsp; 数据库:
				<select name="db" style="display: inline-block;width: 15%;padding-left: 0px;" class="form-control" onchange="changeDB()">
					{% for _db in dbs %}
					<option {% if db == _db.name %}selected="selected"{% endif %} value="{{_db.name}}">{{_db.collectionShowName}}</option>
					{% endfor %}
				</select>
				<input type="submit" value="检索" class="btn btn-primary" />
			</form>
		</div>
		<div style="margin-top:15px;">
			<table id="table" data-toggle="table" data-click-to-select="true" data-row-style="rowStyle" data-height="600">
				<thead>
					<tr>
						<th>ID</th>
						<th>标题</th>
						<th>数据来源</th>
						<th>入库时间</th>
					</tr>
				</thead>
				{% for item in items %}
				<tr>
					<td>{{item.id}}</td>
					<td><a href="detail?id={{item.id}}&db={{db}}" target="_blank">{{item.title}}</a></td>
					<td>{{item.source}}</td>
					<td>{{item.create_time}}</td>
				</tr>
				{% endfor %}
			</table>
		</div>
		<div>
			<nav aria-label="Page navigation">
				<ul class="pagination">
					<li>
						<a href="{{firsturl}}" aria-label="Previous">
							<span aria-hidden="true">&laquo;</span>
						</a>
					</li>
					{% for pg in pgs %} {% if pg.active %}
					<li class="active"><a href="{{pg.url}}">{{pg.text}}</a></li>
					{% else %}
					<li><a href="{{pg.url}}">{{pg.text}}</a></li>
					{% endif %} {% endfor %}
					<li>
						<a href="{{lasturl}}" aria-label="Next">
							<span aria-hidden="true">&raquo;</span>
						</a>
					</li>
					<li><span>Total: {{total}}</span></li>
				</ul>
			</nav>
		</div>
		<div></div>
		<script>
		var num=Math.ceil(Math.random()*10);
		
		</script>
			<a style="display: block; float: left;" onclick="exportData('{{db}}')" href="#">导出当前数据库数据</a>
			<a style="display: block; float: right;" target="_blank" href="https://gitee.com/sunnytu/xltaxspiderjxltaxspider">Source Code</a>
		</div>
	</div>
	<div style="width: 200px;margin: 0 auto;">&copy;用友审计 2016</div>
	<script src="static/js/jquery-2.1.3.min.js"></script>
	<script src="static/js/bootstrap.min.js"></script>
	<script src="static/js/bootstrap-table.min.js"></script>
	<script src="static/js/bootstrap-table-zh-CN.min.js"></script>
	<script>
		function onSelect(obj){
		//	alert($(obj).find('option:selected').text());
			//alert(obj.options[obj.options.selectedIndex].text);
			$('form').submit();
		}
		function changeDB(){
			$('#source').val('全部');
		}
		function exportData(db){
			var source=$('#source').find('option:selected').text()=='全部'?'':$('#source').find('option:selected').text();
			window.location='./exportData?db='+db+'&source='+source;
		}
	</script>
</body>

</html>